﻿using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Prism.Events;
using System.Windows.Media.Imaging;
using Prism.Mvvm;
using Prism.Regions.Behaviors;
using SoonCode.Core;
using SoonCode.FocusTest.Models;
using SoonCode.FocusTest.Utils;

namespace SoonCode.FocusTest.ViewModels.Teacher
{
    internal class SensoryPrintViewModel : BindableBase
    {
        private string _title;
        private SensoryPrintModel _model;
        private BitmapImage? _qrcode;
        private string _printFoot;

        public BitmapImage? QRCode
        {
            get { return _qrcode; }
            set
            {
                _qrcode = value;
                RaisePropertyChanged();
            }
        }

        public string Title
        {
            get { return _title; }
            set
            {
                _title = value;
                RaisePropertyChanged();
            }
        }

        public SensoryPrintModel Model
        {
            get { return _model; }
            set
            {
                _model = value;
                RaisePropertyChanged();
            }
        }

        public string PrintFoot
        {
            get { return _printFoot; }
            set
            {
                _printFoot = value;
                RaisePropertyChanged();
            }
        }

        private IEventAggregator aggregator;

        public SensoryPrintViewModel(IEventAggregator aggregator)
        {
            this.aggregator = aggregator;
        }

        public void SetData(SensoryPrintModel info)
        {
            OrgInfo org = GlobalModel.Instance.OrgInfo;
            Title = org.c_name.IsNullOrEmpty() ? org.name : org.c_name;
            Model = info;
            Bitmap image =
                QRCodeUtil.GenerateQRCodeBitmap("http://focus.xinshengcorp.com/#/device/sensoryReport?id=" +
                                                info.ID);
            QRCode = QRCodeUtil.BitmapToImageSource(image);
            PrintFoot = org.c_printFoot;
        }

    }
}